<?php
    //define ($SERCET_PASSWORD,"pineEntertainment");
    include("AESCipher.php");
    function encrypt($uid)
    {
       $key = "pineEntertainment"; 
       //$byte_array_key = unpack('C*', $key);
       ///echo "<br>size = ".sizeof($byte_array_key)."<br>".$byte_array_key[0];
      $uid = utf8_encode($uid);
       echo $uid;
       $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC); 

      // $key = str_pad($key, $iv_size, "\0", STR_PAD_RIGHT);
      
       echo "<br>".strlen($key);
       echo "<br>".strlen($iv);
      //echo $key;
      
       $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $uid, MCRYPT_MODE_CBC); 
       //echo "<br>".$crypttext;
       return base64_encode($crypttext); 
    }





    include("ProjectContext/WhatIsThePictureContext.php");
	$proxy = new WhatIsThePictureContext();
    //$proxy->Credential = new WindowsCredential("trieunk", "FPT0312S1");
    $user_id = "1000100003275080133";
    $user_name = "000000000000";//12
    //$pass = encrypt($user_id);
    

    $aes = new AESCipher(MCRYPT_MODE_CBC);
    $key = 'pineEntertainment';
    $key  = str_pad($key, 32, "\0", STR_PAD_RIGHT);
    $pass  = base64_encode($aes->encrypt($user_id, $key, NULL));
    
    echo "<br>Password: ".$pass;
    $proxy->Credential = new WindowsCredential($user_name, $pass);
   
    try 
    {
        $response = $proxy
            ->ServerInfos()
            ->Execute();
    }
    catch(DataServiceRequestException $ex)
    {
            echo 'Error: while running the query ' . $ex->Response->getQuery();
            echo "<br/>";
            echo $ex->Response->getError();
    }

    //echo "<br>response";
    $customer = $response->Result[0];
    echo "<br>ID = ".($customer->ID);
    echo "<br>Time = ".($customer->PstNow);
    
    //echo "<br>".encrypt($user_id);
?>